/*=============================================================================

  BACKGROUND MANAGER MODULE

  FILE: BKmgr.h
  
  DESCRIPTION

    Manager Module Definition

  EXTERNALIZED FUNCTIONS

    
  Copyright (c) DaeSung Engineering Inc. All rights reserved.

=============================================================================*/
/*=============================================================================

                             EDIT HISTORY

  ---------  -------  -------------------------------------------------------
    when       who     what, where, why
  ---------  -------  -------------------------------------------------------
   06/28/03   nso4th   Version 0.1

=============================================================================*/

#ifndef _BKMGR_H_
#define _BKMGR_H_

/*=============================================================================
  HEADER INCLUSION
=============================================================================*/
#include <Cust_Target.h>

/*=============================================================================
  CONSTANT DEFINITON
=============================================================================*/

/*=============================================================================
  ENUMERATORS
=============================================================================*/

typedef enum
{
	BKmgr_BASE_E = 0x00,
	
	// Internal usage
	BKmgr_CHANGE_MAJSTATE_E = 0x0100,
	BKmgr_TIMER_0_E,
	BKmgr_TIMER_1_E

} BKmgr_Event_e;

/*=============================================================================
  BKmgr CLASS DEFINITION
=============================================================================*/
class BKmgr : public mgrBase
{
public:
	BKmgr();
	~BKmgr();

public:
	virtual boolean Init(void);
	virtual boolean Close(void);

/*---------------------------------------------------------
  REQUEST FUNCTION (IT'S INTERNAL PROCESSING)
---------------------------------------------------------*/
public:
	boolean REQ_DEVICE(void);
	
// (IT'S INTERNAL PROCESSING)
protected:
	void REQ_LOG(void);
	void REQ_ERR(void);

/*---------------------------------------------------------
  STATE FUNCTION
---------------------------------------------------------*/
protected:
	virtual void STATE_SYNC(mcxt pTask);
	virtual void STATE_POLLING(void);
	
/*---------------------------------------------------------
  MONITORING
---------------------------------------------------------*/
public:
	void MON_LOCK(boolean lock);

protected:
	void MON_STATE(void);
	void MON_LOG(void); // LOG
	
protected:
	void MON_Alloc(void);
	void MON_Free(void);
	
	mcxt	m_monSync;
	boolean	m_reqWait, m_reqLock, m_monLock;
	int32	m_monCnt; 

/*---------------------------------------------------------
  COMMAND
---------------------------------------------------------*/
protected:
	void CMD_LOG(void);
	void CMD_ERR(void);

protected:
	void CMD_Alloc(void);
	void CMD_Free(void);

/*---------------------------------------------------------
  INTERNAL USAGE
---------------------------------------------------------*/
protected:
	dword	m_bkMASK;
	mcxt	m_logFS; // LOG.FILE.SYSTEM
	mcxt	m_errFS; // ERR.FILE.SYSTEM
	Time_s	m_logTODAY, m_errTODAY;
	
	void bkON(dword bkMASK);
	void bkOFF(dword bkMASK);
	void bkSET(dword bkMASK);

/*---------------------------------------------------------
  EVENT HANDLER
---------------------------------------------------------*/
public:
	virtual dword Event_Handler(dword dwType, dword dwEvent, dword wParam, dword lParam);
	dword HEvent_Handler(dword dwType, dword dwEvent, dword wParam, dword lParam);
	dword Event_PreProc(dword dwType, dword dwEvent, dword wParam, dword lParam);

protected:
	void Command_Handler(dword cmd, dword wp, dword lp);
};

#endif /* _DMMGR_H_ */


/*=============================================================================
  EXTERNALIZED FUNCTION DESCRPTIONS
=============================================================================*/
/*--- END OF BKmgr.H ---*/
